#include<iostream>
#include<algorithm>
using namespace std;
int a[100005],b[100005];
int main()
{
	int m,n,dist=0;
	cin>>m>>n;
	for(int i=1;i<=m;i++)
		cin>>a[i];
	sort(a+1,a+m+1);
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		int num=lower_bound(a+1,a+m+1,b[i])-a;
		if(num==1)
			dist+=abs(a[num]-b[i]);
		else if(num==m+1)
			dist+=abs(a[m]-b[i]);
		else
			dist+=min(abs(a[num]-b[i]),abs(a[num-1]-b[i]));
	}
	cout<<dist;
    return 0;
}
